home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 March
/
EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso
/
earcd
/
program
/
bgui12.lha
/
demos
/
filereq.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-20
|
7KB
|
163 lines
;/* Execute me to compile with DICE V3.0.
dcc filereq.c -proto -mi -ms -mRR -3.0 -lbgui
quit
*/
/*
** FILEREQ.C
**
** (C) Copyright 1995 Jaba Development.
** (C) Copyright 1995 Jan van den Baard.
** All Rights Reserved.
**/
#include "democode.h"
#include <libraries/asl.h>
#include <proto/utility.h>
/*
** Bulk GetAttr(). This really belongs in amiga.lib... I think.
**/
ULONG GetAttrs( Object *obj, ULONG tag1, ... )
{
struct TagItem *tstate = ( struct TagItem * )&tag1, *tag;
ULONG num = 0L;
while ( tag = NextTagItem( &tstate ))
num += GetAttr( tag->ti_Tag, obj, ( ULONG * )tag->ti_Data );
return( num );
}
/*
** Put up a simple requester.
**/
ULONG Req( UBYTE *gadgets, UBYTE *body, ... )
{
struct bguiRequest req = { NULL };
req.br_GadgetFormat = gadgets;
req.br_TextFormat = body;
req.br_Flags = BREQF_AUTO_ASPECT;
req.br_Underscore = '_';
return( BGUI_RequestA( NULL, &req, ( ULONG * )( &body + 1 )));
}
VOID StartDemo( void )
{
Object *filereq;
ULONG rc, dr, fl, pt, pa, l, t, w, h;
/*
** Present a simple requester.
**
** NOTE: For some reason the size of the requester is not
** saved when RTPatch (from reqtools) is active. When
** I have some time left I'll take a look and try to
** find out why.
**/
if ( ! Req( "_Continue|_Go Away!", ISEQ_C "This demo shows you how to use the BGUI\n"
"BOOPSI ASL interface. It pops a simple Load requester\n"
"and let's you play with it. After this the requester\n"
"type is changed into a Save requester. Ofcourse the\n"
"current path, requester size and position etc. is saved\n"
"while the object remains valid." ))
return;
/*
** Create a filerequester object.
**/
filereq = FileReqObject, ASLFR_DoPatterns, TRUE, EndObject;
/*
** Object OK?
**/
if ( filereq ) {
/*
** Pop the requester.
**/
if ( ! ( rc = DoRequest( filereq ))) {
/*
** Obtain attribute values.
**/
GetAttrs( filereq, FRQ_Drawer, &dr,
FRQ_File, &fl,
FRQ_Pattern, &pt,
FRQ_Path, &pa,
FRQ_Left, &l,
FRQ_Top, &t,
FRQ_Width, &w,
FRQ_Height, &h,
TAG_END );
/*
** Dump 'm on the console.
**/
Tell( "Drawer : %s\n"
"File : %s\n"
"Pattern : %s\n"
"Path : %s\n"
"Left,Top,Width,Height : %ld,%ld,%ld,%ld\n",
dr, fl, pt, pa, l, t, w, h );
} else if ( rc == FRQ_CANCEL )
/*
** Requester canceled.
**/
Tell("Canceled\n" );
else
/*
** Error.
**/
Tell("Error %ld\n", rc );
/*
** Make it a save requester.
**/
if ( ! ( rc = SetAttrs( filereq, ASLFR_DoSaveMode, TRUE, TAG_END ))) {
/*
** Pop the requester.
**/
if ( ! ( rc = DoRequest( filereq ))) {
/*
** Obtain attribute values.
**/
GetAttrs( filereq, FRQ_Drawer, &dr,
FRQ_File, &fl,
FRQ_Pattern, &pt,
FRQ_Path, &pa,
FRQ_Left, &l,
FRQ_Top, &t,
FRQ_Width, &w,
FRQ_Height, &h,
TAG_END );
/*
** Dump 'm to the console.
**/
Tell( "Drawer : %s\n"
"File : %s\n"
"Pattern : %s\n"
"Path : %s\n"
"Left,Top,Width,Height : %ld,%ld,%ld,%ld\n",
dr, fl, pt, pa, l, t, w, h );
} else if ( rc == FRQ_CANCEL )
/*
** Requester canceled.
**/
Tell("Canceled\n" );
else
/*
** Error.
**/
Tell("Error %ld\n", rc );
} else
/*
** Error with SetAttrs().
**/
Tell( "Error %ld\n", rc );
/*
** Dump the filerequester object.
**/
DisposeObject( filereq);
} else
Tell( "unable to create filerequester object.\n" );
}